<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户反馈</title>
    <meta name="keywords" content="设置关键词..."/>
    <meta name="description" content="设置描述..."/>
    <meta name="author" content="DeathGhost"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <link rel="icon" href="images/icon/favicon.ico" type="image/x-icon">
    <link rel="stylesheet" type="text/css" href="css/style.css"/>
    <link rel="stylesheet" type="text/css" href="BootStrap/css/bootstrap.css">

    <script src="BootStrap/js/jquery.js"></script>
    <script src="BootStrap/js/bootstrap.js"></script>
</head>
<body>
<div class="page-wrap">
    <section class="page-hd">
        <header>
            <h2 class="title">用户反馈</h2>
        </header>
        <hr>
    </section>
    <div class="breadcrumb">
        <ul>
            <li><a>设置</a><i class="icon-angle-right"></i></li>
            <li><a href="gudonghefenxiaoshangtable.html">用户反馈</a><i class="icon-angle-right"></i></li>
            <li>详情</li>
        </ul>
    </div>

</div>

<div class="page-wrap">

    <form id="myform" class="form-inline">

        <br>
        反馈时间:<br>
        <input type="text" class="form-control" placeholder="开始时间" style="width:280px"  name="minTime">~
        <input type="text" class="form-control" placeholder="结束时间" style="width:280px " name="maxTime">
        <button type="button" class="btn btn-primary" name="Se">搜索</button>
        <button  class="btn btn-default" name="cl">清除</button><br>
        <br>
    </form>
</div>

<div class="breadcrumb">
    <table class="table table-striped table-bordered table-hover" style="width: 100%;margin: 20px auto">
        <thead>
        <tr class='cen'>
            <th>编号</th>
            <th>反馈内容</th>
            <th>图片</th>
            <th>提交人手机号</th>
            <th>反馈时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="tbody">

        </tbody>
    </table>
    <ul class="pagination pull-right" id="page">

    </ul>
</div>

<!--删除模态框开始-->
<div class="modal fade" id="delFeedback_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <h1 style="text-align: center">你确认要删除吗？</h1>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="delFeedback">删除</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!--删除模态框结束-->
<script>
    getAll(1);

    function getAll(pageNumber) {
        var minTime = $("[name=minTime]").val();
        var maxTime = $("[name=maxTime]").val();
        $.ajax({
            url: '/feedback/list',
            type: 'post',
            data: {"minTime": minTime, "maxTime": maxTime, "pageNumber": pageNumber},
            success: function (data) {
                if (data.result == true) {
                    var str = "";
                    for (var i = 0; i < data.fankui.length; i++) {
                        str += "<tr class='cen'>";
                        str += "<td >" + data.fankui[i].userfeedbackid + "</td>";
                        str += "<td>" + data.fankui[i].userfeedbackcontent + "</td>";
                        str += "<td>" + data.fankui[i].userfeedbackimage + "</td>";
                        str += "<td>" + data.fankui[i].sesUser.userphone + "</td>";
                        str += "<td>" + data.fankui[i].userfeedbackdate + "</td>";
                        str += "<td>";
                        str += "<input type='hidden' name='userfeedbackId' value='" + data.fankui[i].userfeedbackid + "'>";
                        str += " <a  name='del'> 删除</a>";
                        str += "</td></tr>";

                    }
                    $("#tbody").html(str);
                    var page = "";
                    page += '<li class="' + (data.page.pageNum == 1 ? 'disabled' : '') + '"><a onclick="getAll(' + data.page.prePage + ')" >上一页</a></li>';
                    for (var i = 1; i <= data.page.pages; i++) {
                        page += ' <li class="' + (data.page.pageNum == i ? 'active' : '') + '"><a onclick="getAll(' + i + ')">' + i + '<span class="sr-only"></span></a></li>';
                    }
                    page += ' <li ><a onclick="getAll(' + data.page.nextPage + ')" >下一页</a></li>';
                    $("#page").html(page);
                }
                del();
                delFeedback();
            }
        });

    }


    //删除弹出模态框

    function del() {
        $("[name=del]").click(function () {
            $("#delFeedback_modal").modal("show");
        })

    }

    //确认删除删除模态框
    delFeedback();

    function delFeedback() {
        var userfeedbackId = $("[name=userfeedbackId]").val();

        $("#delFeedback").click(function () {
            $.ajax({
                type: 'post',
                url: '/feedback/delete',
                data: {"userfeedbackId": userfeedbackId},
                success: function (data) {
                    $("#delFeedback_modal").modal("hide");
                    getAll(1);
                }
            });
        })
    }
    se();
    function se() {
        $(":button[name=Se]").click(function (){
            getAll(1);
        });

    }
    function cl() {
        $(":button[name=cl]").click(function (){
            $("#myform")[0].reset();
            getAll(1);
        });
    }

</script>
</body>
</html>